<template>
	<view class="sendConditionBgc">
		<view class="textareaVaule">
			<textarea value="" placeholder="谈吐文明的人更受欢迎，请勿发布低俗、色情交易或 曝光他人隐私的内容" v-model="textareaVaule" />
			</view>
		<view class="uploadPic">
			<u-upload :action="action" max-count="3" :file-list="fileList"  @on-uploaded="onUploaded" :show-progress='false'
			 :deletable='false'></u-upload>
		</view>
		<view class="hint">
			女性未认证不能发布广播，否则收费10社区币
		</view>
		<view class="sureSend"@click="sureSendBtn">
			确认发布
		</view>
	</view>
</template>

<script> 
import {url} from "@/utils/api"
	export default {
		data() {
			return {
				textareaVaule:'',
				action: url+'/image/upload',
				fileList: [],
				picList:[]
			}
		},
		created() {
		}, 
		onLoad(options) {
		},
		methods: {
			onUploaded(e){
				let index=0
				this.picList.push(e[index].response.url)
				index++
				if(index == 2){
					index=0
				}
			},
			sureSendBtn(){
				if(this.textareaVaule ==''){
					uni.showToast({
						title: '请输入动态内容',
						duration: 1000,
						icon: 'none'
					});
					return
				}else if(this.picList.length <=0){
					uni.showToast({
						title: '请上传图片',
						duration: 1000,
						icon: 'none'
					});
					return
				}else {
					let data={
						content:this.textareaVaule,
						images:this.picList
					}
					this.$u.post('/publish',data).then(res => {
										if(res){
											console.log(res,'ressss')
											uni.showToast({
												title: res.message,
												duration: 1000,
												icon: 'none'
											});
											setTimeout(()=>{
												uni.switchTab({
													url:'../indexPage/station'
												})
											},1000)
										}
									})
									.catch((res) => {
										console.log(res.message)
									})
				}
			},
		}
	}
</script>

<style>
	.sendConditionBgc{
		background-color: #F9F6FF;
		width: 100%;
		height: 100%;
	}
	.textareaVaule{
		width:100%;
		height:320rpx;
		background:rgba(255,255,255,1);
		padding: 28rpx;
		border-top: 14rpx solid #F9F6FF;
	}
	.textareaVaule textarea{
		width:100%;
		height:100%;
		color:rgba(102,102,102,1);
		font-size: 30rpx;
	}
	.uploadPic{
		width:100%;
		height:266rpx;
		background:rgba(255,255,255,1);
		margin-top: 14rpx;
		padding: 29rpx;
	}
	.hint{
		margin: 30rpx auto;
		text-align: center;
		font-size:26rpx;
		color: #5C14FF;
		}
		.sureSend {
			width: 686rpx;
			height: 98rpx;
			background: #5B13FF;
			border-radius: 49rpx;
			line-height: 98rpx;
			text-align: center;
			color: white;
			margin: 100rpx auto 100rpx;
			font-size: 36rpx;
		}
</style>
